<?php


namespace Before\Builder;


class Client
{
    public static function main()
    {
        // 需要自己创建类，并且手动构造不同大小的产品

        // 创建小型产品
        $product1 = new Product();
        $product1->setPartA('One');

        $product1->show();


        // 创建大型产品
        $product2 = new Product();
        $product2->setPartB('Two');
        $product2->setPartC('Two');
        $product2->setPartC('Two');

        $product2->show();
    }
}


class Product
{
    protected string $partA;
    protected string $partB;
    protected string $partC;

    public function setPartA(string $partA): void
    {
        $this->partA = $partA;
    }

    public function setPartB(string $partB): void
    {
        $this->partB = $partB;
    }

    public function setPartC(string $partC): void
    {
        $this->partC = $partC;
    }

    public function show(): void
    {
        echo json_encode(array_filter(get_object_vars($this))), PHP_EOL;
    }
}


Client::main();
